<template>
  <div>
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="用户编号" align="center" prop="idNo"/>
      <el-table-column label="申请时间" align="center">
        <template slot-scope="scope">
          <span>{{ dateFormat(scope.row.createtime,'YYYY-MM-DD HH:mm') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="角色" align="center" prop="role" :formatter="typeFormat"/>
      <el-table-column label="真实姓名" align="center" prop="realname"/>
      <el-table-column label="手机号" align="center" prop="mobile"/>
      <el-table-column label="账号类型" align="center" prop="accounttype"/>
      <el-table-column label="账号" align="center" prop="idcard">
        <template slot-scope="scope">
          <el-popover placement="top-start" title="账号" width="250" trigger="hover">
            <div>{{scope.row.idcard}}</div>
            <span slot="reference">{{ scope.row.idcard.substr(0,10)+'...' }}</span>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="支行信息" align="center" prop="accountbranch"/>
      <el-table-column label="申请金额" align="center">
        <template slot-scope="scope">
          <div>
            {{formatCurrency(scope.row.amount+scope.row.fee)}}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="手续费" align="center">
        <template slot-scope="scope">
          <span>{{formatCurrency(scope.row.fee) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实提金额" align="center">
        <template slot-scope="scope">
          <span>{{formatCurrency(scope.row.amount) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" :formatter="typeFormat"/>

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import {take} from "@/api/main/financial/user";
  export default {
    props: {
      platCustNo: {
        type: String,
        require: true
      }

    },
    data() {
      return {
        postList: [],
        loading: false,
        total: 0,
        takeStatusOptions: [],
        roleOptions: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderByColumn: 'T1.createtime DESC'
        }
      }
    },
    created() {
      this.queryParams.platCustNo=this.platCustNo;
      this.getDicts("yy_user_role").then(response => {
        this.roleOptions = response.data;
      });
      this.getDicts("yy_take_status").then(response => {
        this.takeStatusOptions = response.data;
      });
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        take(this.queryParams).then(response => {
          console.log(response.rows);
          this.postList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      typeFormat(row, column) {
        let option;
        if (column.property === 'role') {
          option = this.roleOptions;
        } else if (column.property === 'status') {
          option = this.takeStatusOptions;
        }
        return this.selectDictLabel(option, row[column.property]);
      }
    }
  }
</script>

<style scoped>

</style>
